package com.mk.legoscans2.data;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

public class ErrorReoportingSerivice {

	public void reportBrokenImage(String scanId, int page)
	{
		HttpPost httpPost = new HttpPost("http://api.legoscans.com/log/reporterror?source=android");
	    try {
	        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
	        nameValuePairs.add(new BasicNameValuePair("id", scanId));
	        nameValuePairs.add(new BasicNameValuePair("page", page + ""));
			httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

			new DefaultHttpClient().execute(httpPost);
        } catch (UnsupportedEncodingException e) {
		} catch (ClientProtocolException e) {
		} catch (IOException e) {}
	}
	
	public void reportBrokenThumbnail(String scanId)
	{
		reportBrokenImage(scanId, 0);
	}
}
